﻿@using System.Text.RegularExpressions;

@{ 


    ViewBag.Title = "文件管理";



    String[] paths = new String[0];
    Dictionary<String, String> mapper = new Dictionary<String, String>();
    if (ViewBag.CurrentPath != null && !"".Equals(ViewBag.CurrentPath)) {
        paths = new Regex("^/*(.*?)/*$").Replace(ViewBag.CurrentPath, "$1").Split('/');
    }

    String basePath = "";
    for (int i = 0; i < paths.Length; ++i)
    {
        if (i > 0)
        {
            basePath += paths[i];
        }
        else {
            basePath = "/" + paths[i];
        }
        basePath += "/";
        mapper.Add(paths[i], basePath);
    }

}


<h4 class="bg-primary">当前路径：/<a href="/FileManage/ListFile">upload</a>/@foreach(String path in paths){<a href="/FileManage/ListFile@(mapper[path])">@path</a><span>/</span>}</h4>

@if (@ViewBag.ErrMsg != null)
{
    <div class="alert alert-warning" role="alert"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> @ViewBag.ErrMsg</div>
}
else
{
    <div class="panel panel-default">
        <div class="panel-heading">本目录中共有@(ViewBag.FolderNumber)个文件夹及@(ViewBag.FileNumber)个文件。</div>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>文件名</th>
                    <th>尺寸</th>
                    <th>上传日期</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var Item in ViewBag.FileList)
                {
                    <tr>
                        <td>
                            @if (Item.IsDir)
                    {
                            <span class="glyphicon glyphicon-folder-open"></span>
                        }
                        else
                        { <span class="glyphicon glyphicon-picture"></span> } @{if (Item.IsDir)
                            { <a href="/FileManage/ListFile@(Item.RelativePath)/">@Item.FileName</a>}
                            else
                            { <a target="_image_" href="/upload/@Item.RelativePath">@Item.FileName</a> }
                        }
                    </td>
                    <td>@Item.getReadableSize()</td>
                    <td>@Item.CreateDate</td>
                    <td><a href="/FileManage/DelFile/@(ViewBag.CurrentPath)?file=@Item.FileName"><span class="glyphicon glyphicon-trash"></span></a></td>
                </tr>
                            }
            </tbody>
        </table>
    </div>
    

}
